package com.dodoke.controller;

import java.util.List;

import com.dodoke.domain.WxQr;
import com.dodoke.service.IWxQrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dodoke.common.annotation.Log;
import com.dodoke.common.core.controller.BaseController;
import com.dodoke.common.core.domain.AjaxResult;
import com.dodoke.common.enums.BusinessType;
import com.dodoke.common.utils.poi.ExcelUtil;
import com.dodoke.common.core.page.TableDataInfo;

/**
 * 【二维码（废弃）】Controller
 * 
 * @author dodoke
 * @date 2020-08-25
 */
@RestController
@RequestMapping("/qr")
@Api("二维码模块")
public class WxQrController extends BaseController
{
    @Autowired
    private IWxQrService wxLevelOneQrService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:qr:list')")
    @GetMapping("/list")
    public TableDataInfo list(WxQr wxQr)
    {
        startPage();
        List<WxQr> list = wxLevelOneQrService.selectWxLevelOneQrList(wxQr);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:qr:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WxQr wxQr)
    {
        List<WxQr> list = wxLevelOneQrService.selectWxLevelOneQrList(wxQr);
        ExcelUtil<WxQr> util = new ExcelUtil<WxQr>(WxQr.class);
        return util.exportExcel(list, "qr");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:qr:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wxLevelOneQrService.selectWxLevelOneQrById(id));
    }

    /**
     * 新增【二维码】
     */
    @Log(title = "【新增二维码】", businessType = BusinessType.INSERT)
    @ApiOperation("生成新的二维码")
    @ApiImplicitParam(name = "wxQr",value = "二维码对应的实体类",dataType = "body")
    @PostMapping
    public AjaxResult add(@RequestBody WxQr wxQr)
    {
        return toAjax(wxLevelOneQrService.insertWxLevelOneQr(wxQr));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:qr:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxQr wxQr)
    {
        return toAjax(wxLevelOneQrService.updateWxLevelOneQr(wxQr));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:qr:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wxLevelOneQrService.deleteWxLevelOneQrByIds(ids));
    }
}
